/**
 * 
 */
package tech.abing.spider.task.pageprocessor.amac;

import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;

import org.apache.log4j.Logger;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import tech.abing.spider.component.PageProcessor;
import tech.abing.spider.component.PageScript;
import tech.abing.spider.model.Proccessable;
import tech.abing.spider.page.OkPage;
import tech.abing.spider.page.Page;
import tech.abing.spider.request.BasicRequest;
import tech.abing.spider.request.StartContext;
import tech.abing.spider.task.model.amac.AdminPunishDetailEntity;
import tech.abing.spider.util.UuIdPublic;

/**
 * 类说明
 * @author HUNING
 * @since 2017-11-29
 * 
 */
public class AdminPunishDetailProcessor implements PageProcessor{

	private static Logger logger = Logger.getLogger(AdminPunishDetailProcessor.class);
	@Override
	public PageScript getJavaScript() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Pattern getNormalContain() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void process(OkPage page, StartContext context, List<BasicRequest> queue, List<Proccessable> objectContainer)
			throws Exception {
		Document doc = Jsoup.parse(page.getContent());
		String url = page.getRequest().getUrl();
		AdminPunishDetailEntity detail = new AdminPunishDetailEntity();
		Element ele = doc.select("body > div > div > div.er_main > div").first();
		detail.setContent(ele.select(".content").text());
		detail.setCreateTime(new Date());
		detail.setId(UuIdPublic.timeStrongID(5));
		detail.setSource(ele.select(".time > span:nth-child(2) ").text());
		detail.setTime(ele.select(".time > span:nth-child(1) ").text());
		detail.setTitle(ele.select(".title").text());
		detail.setLinkUrl(url);
		objectContainer.add(detail);
		
	}

	@Override
	public void processErrorPage(Page page, StartContext context, List<Proccessable> objectContainer) throws Exception {
		// TODO Auto-generated method stub
		
	}

}
